package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.Offline;
import com.indusfo.spc.service.OfflineService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 维修线下信息控制层
 */
@Controller
@RequestMapping("/offline")
public class OfflineController {
    @Autowired
    private OfflineService offlineService;

    /**
     * 修改维修线下信息
     *
     * @param offline
     * @return
     */
    @RequestMapping(value = "/updateOffline",method= RequestMethod.POST)
    @SystemControllerLog(description="修改维修线下信息")
    @ResponseBody
    public JSONObject updateOffline(@RequestBody Offline offline){

        JSONObject json=offlineService.updateOffline(offline);
        return json;
    }

    /**
     * 查询维修线下信息
     *
     * @param offline
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryOffline")
    @SystemControllerLog(description="查询维修线下信息")
    @ResponseBody
    public JSONObject queryOffline(Offline offline) {

        JSONObject json = offlineService.selectAll(offline);
        return json;
    }

    /**
     * 插入维修线下信息
     *
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertOffline", method= RequestMethod.POST)
    @SystemControllerLog(description="新增维修线下信息")
    @ResponseBody
    public JSONObject insertOffline(Offline offline) {

        JSONObject json = offlineService.insertOffline(offline);
        return json;
    }

    /**
     * 启用/停用 维修线下信息
     *
     * @param offlineIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definesOffline", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用维修线下信息")
    @ResponseBody
    public JSONObject definesOffline(Long[] offlineIds, Integer dataState) {

        JSONObject json = offlineService.deleteOffline(offlineIds, dataState);
        return json;
    }

    /**
     * 删除维修线下信息
     *
     * @param offlineIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteOffline", method= RequestMethod.POST)
    @SystemControllerLog(description="删除维修线下信息")
    @ResponseBody
    public JSONObject delDep(Long[] offlineIds, Integer dataState) {

        dataState = 2;
        JSONObject json = offlineService.deleteOffline(offlineIds, dataState);
        return json;
    }
}
